/**
 * @author Linrui
 * @since 2011-04-26
 * 新闻菜单的拦截器
 */
package com.qeado.util.interceptors;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import com.qeado.news.service.NewsService;
import com.qeado.news.web.NewsAction;
import com.qeado.sort.model.Sort;
import com.qeado.sort.service.SortService;

@Component
public class NewsInterceptor extends AbstractInterceptor {
	
	private NewsAction newsAction;
	@Autowired
	private SortService sortService; 
	@Autowired
	private NewsService newsService;
	
	private List<Sort> sortList; // 类别菜单
	
	@Override
	public String intercept(ActionInvocation invocation) throws Exception {
		newsAction = (NewsAction)invocation.getAction();
		/* 如果session中不存在sortList的值，则重新加载 */
		if( newsAction.getSortList() == null) {
			sortList = sortService.listByPcode("NE");
			newsAction.setSortList(sortList);
		} 
		return invocation.invoke();
	}
	
}
